#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>

using namespace std;

int main() {
    double sum = 0;

    for (int i = 1; i <= 3; ++i) {
        string line;
        double score;
        bool valid = false;

        do {
            cout << "Enter test " << i << " score: ";
            getline(cin, line);
            istringstream iss(line);
            
            if (iss >> score) {

                char remaining;
                if (score < 0 or score > 100) {
                    cout << "Invalid. Score must be between 0 and 100." << endl;
                } else {
                    valid = true;
                }
            } else {
                cout << "Invalid input. Please enter a numeric value." << endl;
            }
        } while (!valid);

        sum += score;
    }

    double average = sum / 3;
    char grade;

    if (average >= 90) {
        grade = 'A';
    } else if (average >= 80) {
        grade = 'B';
    } else if (average >= 70) {
        grade = 'C';
    } else if (average >= 60) {
        grade = 'D';
    } else {
        grade = 'F';
    }

    cout << fixed << setprecision(2);
    cout << "Average: " << average << endl;
    cout << "Grade: " << grade << endl;

    return 0;
}